package cn.gotom.asvg;

import java.io.File;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.Menu;
import cn.gotom.logging.log4j.LogConfigurator;
import cn.gotom.svg.xml.XMLParseUtil;

public class MainActivity extends Activity
{
	private final LogConfigurator logConfigurator = new LogConfigurator();
	protected final Logger log = Logger.getLogger(MainActivity.class);

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		logConfigurator();
		// setContentView(R.layout.activity_main);
		XMLParseUtil.getPixPerInch(this);
		SVGView view = new SVGView(this);
		view.load(R.raw.test);
		setContentView(view);
//		SVGImageView view = new SVGImageView(this);
//		view.setImageResource(R.raw.test);
		this.setContentView(view);
	}

	public void logConfigurator()
	{
		try
		{
			//Environment.getExternalStorageDirectory().getPath();
			final String filename = getApplicationContext().getFilesDir().getAbsolutePath() + File.separator + this.getPackageName() + ".log";
			Log.e("", filename);
			logConfigurator.setFileName(filename);
			logConfigurator.setRootLevel(Level.DEBUG);
			logConfigurator.setLevel("org.apache", Level.ERROR);
			logConfigurator.configure();
		}
		catch (Exception ex)
		{
			Log.e(this.getPackageName(), ex.getMessage());
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
}
